"; $outtext .= ""; $outtext .= ""; $outtext .= "".DogFullName($id, FALSE, FALSE, array('color' => '#ce185d'))."".($addinfo?"
$addinfo
":"").""; $outtext .= ""; $outtext .= ""; return $outtext; } function DogBlockSm ($id, $addinfo = FALSE) { $outtext .= ""; $outtext .= ""; $outtext .= ""; $outtext .= ""; $outtext .= ""; $outtext .= ""; $outtext .= ""; $outtext .= "
".DogFullName($id, FALSE, FALSE, array('color' => '#ce185d'))."".($addinfo?"
$addinfo
":"")."
"; return $outtext; } function DogFullName($id, $withlink=FALSE, $addinfo = FALSE, $params = FALSE) { GLOBAL $if; // ìàññèâ âèçóàëüíûõ ïàðàìåòðîâ if(!$id) $retstr=$if['dog_name_unknown']; else { $row = data_select( array('id' => 0, ($if['id'] == 1)?'name':'engname' => ($if['id'] == 1)?0:'name', 'rkf' => 0, 'owner' => 0, 'breeder' => 0, 'countryid' => 0 , 'active' => 0), array('id' => (int)$id), array('dogs' => 0)); $retstr = str_replace("&", "&", $row['name']?$row['name']:$id); $rkf = $row['rkf']; if($params['upper']) $retstr = "$retstr"; if($params['blank']) $addinfo=" target=_blank>"; else $addinfo=">"; if($withlink && $id && !$params['editlink']) $retstr=""; if($withlink && $id && $params['editlink']) $retstr=""; if(!$withlink && $params['color']) $retstr="$retstr"; if($params['activeness']) $retstr .= ($row['active'] == 1)?" (+)":" (-)"; }; return $retstr; }; function DogSex($sex) { GLOBAL $if; switch($sex) { case 1: $retstr = $if['common_female']; break; case 2: $retstr = $if['common_male']; break; }; return $retstr; } function ShowCompType($id) { GLOBAL $if; $query = "SELECT * FROM comptype WHERE id=$id"; SQLConn(); $row=mysql_fetch_array(mysql_query($query)); if($row['name']) $retstr = $row['name']; else $retstr=$if['dog_name_unknown']; return $retstr; }; function Alted($dtstr) { GLOBAL $if; if($dtstr) $retstr = $dtstr; else $retstr = $if['dog_name_unknown'];; return $retstr; }; function ShowDogPhoto($id,$n,$size = 350, $withlink=FALSE) { switch($n) { case 0: $w=$size; $border=1; break; case 1: $w=$size; $border=1; break; case 2: $w=$size; $border=1; break; case 3: $w=$size; $border=1; break; case 4: $w=$size; $border=1; break; }; if($withlink && file_exists("ph/$id-$n.jpg")) { $before=""; $after=""; }; if(file_exists("ph/$id-$n.jpg")) $retstr=""; else $retstr=""; return $before.$retstr.$after; }; function ShowDogPhotoLB($id,$n,$size = 350, $withlink=FALSE) { switch($n) { case 0: $w=$size; $border=1; break; case 1: $w=$size; $border=1; break; case 2: $w=$size; $border=1; break; case 3: $w=$size; $border=1; break; case 4: $w=$size; $border=1; break; case 5: $w=$size; $border=1; break; case 6: $w=$size; $border=1; break; case 7: $w=$size; $border=1; break; }; if($withlink && file_exists("ph/$id-$n.jpg")) { $before=""; $after=""; }; if(file_exists("ph/$id-$n.jpg")) $retstr=""; else $retstr=""; return $before.$retstr.$after; }; function ShowDogXrays($id,$size = 350, $type=1) { if($type == 1) $n = "hd"; else $n = "ed"; if(file_exists("xrays/$id-$n.jpg")) { // $before=""; $before=""; $after=""; }; if(file_exists("xrays/$id-$n.jpg")) $retstr=""; else $retstr=""; return $before.$retstr.$after; }; function ShowTitles($id,$ebr="
",$limit=FALSE) { GLOBAL $if; $qstr = "select ". (($if['id'] != 1 || $limit)?"engname AS name":"name") .",count,iscount,color,comment from titlestype,titles WHERE titles.dogid=".(int)$id." AND titles.tid=titlestype.id ORDER BY rang,name"; $dta=mysql_query($qstr); $i = 0; if($dta) { while($row=mysql_fetch_array($dta)) { $i++; if($limit>0 && $i > $limit) { $retstr = $retstr . "$ebr..."; break; } if($limit>0) $row['name'] = str_replace("(USSR)", "", $row['name']); if($row['iscount'] && $row['count'] && ($row['count']>1)) $retstr = $retstr.($retstr?"$ebr":"")."{$row['count']} x {$row['name']}".($row['comment']?" {$row['comment']}":"")."\n"; else $retstr = $retstr.($retstr?"$ebr":"")."{$row['name']}".($row['comment']?" {$row['comment']}":"").""; } } return $retstr; }; function ShowCert($id,$ebr="
") { SQLConn(); $qstr = "SELECT name,count from certtype,cert WHERE cert.dogid=".(int)$id." AND cert.certid=certtype.id ORDER BY rang, certid"; $dta=mysql_query($qstr); if($dta) while($row=mysql_fetch_array($dta)) $retstr = $retstr.($retstr?"$ebr":"")."{$row['count']} x {$row['name']}"; return $retstr; }; function ShowRKF($id) { if($id) $retstr = data_select( array('rkf' => 0, 'addrkf' => 0), array('id' => (int)$id), array('dogs'=>0)); return $retstr['rkf']. ($retstr['addrkf']?" / {$retstr['addrkf']}":""); }; function ShowNames($id,$table,$eng = FALSE) { GLOBAL $if; if(!$id) $id="NULL"; $retstr = data_select( array($eng?'engname':'name' => $eng?'name':0), array('id' => (int)$id), $table); if($if[$retstr['name']]) $retstr['name'] = $if[$retstr['name']]; return $retstr['name']; }; function ShowHealth($id,$ebr="
") { GLOBAL $if; $hd = data_select('*', array('dogid' => (int)$id), 'doghealth'); if($hd['pl_left']) $plstr = ShowNames($hd['pl_left'],'pl'); if($hd['pl_right']) $plstr .= ($plstr?"/":"").ShowNames($hd['pl_right'],'pl'); if($hd['tipss']) $tipssstr = $if['dog_title_tipss'].": ".ShowNames($hd['tipss'],'dna'); if($hd['pra']) $prastr = $if['dog_title_pra'].": ".ShowNames($hd['pra'],'dna'); if($hd['pd']) $pdstr = $if['dog_title_pd'].": ".ShowNames($hd['pd'],'dna'); if($hd['ca']) $castr = $if['dog_title_ca'].": ".ShowNames($hd['ca'],'dna'); if($hd['hd_left']) $hdstr = ShowNames($hd['hd_left'],'hd'); if($hd['hd_right']) $hdstr .= ($hdstr?"/":"").ShowNames($hd['hd_right'],'hd'); if($hd['ed_left']) $edstr = ShowNames($hd['ed_left'],'ed'); if($hd['ed_right']) $edstr .= (($edstr != "")?"/":"").ShowNames($hd['ed_right'],'ed'); $hdstr = (($hd['hd_left']||$hd['hd_right'])?"HD-":"").$hdstr; $edstr = (($hd['ed_left']||$hd['ed_right'])?"ED-":"").$edstr; $plstr = (($hd['pl_left']||$hd['pl_right'])?"PL-":"").$plstr; if($plstr) $healthstr .= ($healthstr?$ebr:"").$plstr; if($hdstr) $healthstr .= ($healthstr?$ebr:"").$hdstr; if($edstr) $healthstr .= ($healthstr?$ebr:"").$edstr; if($tipssstr) $healthstr .= ($healthstr?$ebr:"").$tipssstr; if($prastr) $healthstr .= ($healthstr?$ebr:"").$prastr; if($pdstr) $healthstr .= ($healthstr?$ebr:"").$pdstr; if($castr) $healthstr .= ($healthstr?$ebr:"").$castr; return $healthstr; } function ShowStudy($id,$ebr="
") { SQLConn(); $qstr = "select name,level,islevel from studytype,study WHERE study.dogid=".(int)$id." AND study.studyid=studytype.id ORDER BY studyid"; $dta=mysql_query($qstr); if($dta) { while($row=mysql_fetch_array($dta)) if($row['islevel']) $retstr = $retstr. ($retstr?$ebr:"")."{$row['name']} - {$row['level']}"; else $retstr = $retstr.($retstr?$ebr:"")."{$row['name']}"; } return $retstr; }; function Is_admin($uid=FALSE) { SQLConn(); if($uid) $dta = data_select(array('role'=>0), array('id' => (int)$uid), array('users' => 0)); if($dta['role'] == 1) $retstr = TRUE; else $retstr = FALSE; return $retstr; }; function Whois($id,$table) { if(!$id || $id<1 || !$table) $retstr=FALSE; else { $dt = data_select(array('userid'=>0), array('id' => (int)$id), array($table=>0)); $retstr= $dt['userid']; } return $retstr; }; function Is_Vip($userid) { $dt = data_select('vip', array('id' => (int)$userid), 'users'); return $dt['vip'] || is_admin($userid); } function UpdateDate($dogid) { $chk = data_select('date_up', array('dogid' => $dogid), 'upd'); if(!$chk) mysql_query("INSERT INTO upd(dogid, date_up) VALUES($dogid, \"".Date("Ymd")."\")"); else mysql_query("UPDATE upd SET date_up=\"".Date("Ymd")."\" WHERE dogid=".(int)$dogid); }; /* function UpdateDate($dogid) { mysql_query("UPDATE dogs SET dateupd=\"".ConvertDate(Date("d.m.Y"),TRUE)."\" WHERE id=".(int)$dogid); }; */ function IsActive($dogid) { if($dogid == "") $dogid="NULL"; $row = data_select(array('active' => 0), array('id' => (int)$dogid), array('dogs' => 0)); return $row['active']; }; function xs($str) { // $retstr = preg_replace("/\'/","`",$str); // return $retstr; return $str; }; function xz($str) { $retstr = ereg_replace(",",".",$str); return $retstr; }; function xs_a($arr) { foreach($arr as $an => $av) $arr['$an'] = xs($av); return $arr; }; function ShowRights($dogid, $pid) { $dta = data_select(array('value' => 0), array('dogid' => (int)$dogid,'pid' => (int)$pid), array('fotorights'=>0)); $retstr = str_replace("&", "&", $dta['value']); return $retstr; }; function Shield($textstr, $search = FALSE) { $retstr = htmlspecialchars(strip_tags($textstr)); if($search) { $retstr = trim($retstr); $retstr = str_replace("-","%",$retstr); $retstr = str_replace(" ","%",$retstr); $retstr = strtoupper($retstr); } return $retstr; }; function BadPlus($userid) { $bc = mysql_fetch_array(mysql_query("SELECT badcount FROM users WHERE id=$userid")); $bc = $bc['badcount'] + 1; mysql_query("UPDATE users SET badcount=$bc ".(($bc>2)?", active = 0 ":"")." WHERE id=$userid"); } function LoadPhoto($id,$app,$newfoto,$type=1) { GLOBAL $if; if(!$id) $err .= $if['err_dog_not_selected']; $x = GetImageSize($newfoto); if($x['mime'] != "image/jpeg" && $x['mime'] != "image/gif") $err .= $if['err_photo_not_jpeg']; if(!$err) { switch($type) { case 1: $newname = "ph/$id-$app.jpg"; break; case 2: $newname = "xrays/$id-hd.jpg"; break; case 3: $newname = "xrays/$id-ed.jpg"; break; case 4: $newname = "shows/$id-$app.jpg"; break; case 5: $newname = "archive/$id-$app.jpg"; break; case 6: $newname = "docs/$id-$app.jpg"; break; case 7: $newname = "judges/$id-$app.jpg"; break; } $nx = (($x[0]<940) || ($type == 5))?$x[0]:940; $ny = round($nx/$x[0]*$x[1]); if($x['mime'] == "image/jpeg") $b = imageCreateFromJpeg($newfoto); else $b = imageCreateFromGif($newfoto); $a = imagecreatetruecolor($nx, $ny); ImageCopyResized($a, $b, 0, 0, 0, 0, $nx, $ny, $x[0], $x[1]); $errflag = ImageJpeg($a,$newname); } return $err; }; function NormURL($urltxt) { if(substr($urltxt,0,7) != "http://") $urltxt = "http://$urltxt"; return $urltxt; } function AddStatRecord($id) { $ip = $_SERVER['REMOTE_ADDR']; mysql_query("INSERT INTO dogstat VALUES(".(int)$id.", '$ip', '".ConvertDate(Date("d.m.Y"),TRUE)."', '".Date("H:i:s")."')"); } function ShowDogStat($id) { $d = mysql_query("SELECT COUNT(id) as cnt FROM dogstat WHERE id=$id"); if(mysql_num_rows($d)) $r = mysql_fetch_array($d); return "×èñëî ïîñåùåíèé ñòðàíèöû - {$r['cnt']}"; } function DogPhotoUpd($id) { if(file_exists("ph/$id-0.jpg")) $p0 = 1; else $p0 = 0; if(file_exists("ph/$id-1.jpg")) $p1 = 1; else $p1 = 0; if(file_exists("ph/$id-2.jpg")) $p2 = 1; else $p2 = 0; if(file_exists("ph/$id-3.jpg")) $p3 = 1; else $p3 = 0; if(file_exists("ph/$id-4.jpg")) $p4 = 1; else $p4 = 0; if(mysql_num_rows(mysql_query("SELECT id FROM photos WHERE id=".(int)$id))>0) mysql_query("UPDATE photos SET p0=$p0, p1=$p1, p2=$p2, p3=$p3, p4=$p4 WHERE id=".(int)$id); else mysql_query("INSERT INTO photos VALUES(".(int)$id.",$p0,$p1,$p2,$p3,$p4)"); } function DogJointPicsUpd($id) { if(file_exists("xrays/$id-hd.jpg")) $hd = 1; else $hd = 0; if(file_exists("xrays/$id-ed.jpg")) $ed = 1; else $ed = 0; if(mysql_num_rows(mysql_query("SELECT id FROM jointpics WHERE id=".(int)$id))>0) mysql_query("UPDATE jointpics SET hd=$hd, ed=$ed WHERE id=".(int)$id); else mysql_query("INSERT INTO jointpics VALUES(".(int)$id.",$hd,$ed)"); } function BISResults($showid) { GLOBAL $if; $sn = data_select('*', array('id' => (int)$showid), 'shows'); if($sn['br']>0) $outr[$sn['br']] .= (($outr[$sn['br']]<>"")?", ":"")."{$if['show_bis_reproductor']} - {$sn['br_p']}"; if($sn['bpair_m']>0) { $outr[$sn['bpair_m']] .= (($outr[$sn['bpair_m']]<>"")?", ":"")."{$if['show_bis_pair']} - {$sn['bpair_p']}"; $outr[$sn['bpair_f']] .= (($outr[$sn['bpair_f']]<>"")?", ":"")."{$if['show_bis_pair']} - {$sn['bpair_p']}"; } if($sn['bb']>0) $outr[$sn['bb']] .= (($outr[$sn['bb']]<>"")?", ":"")."{$if['show_bis_baby']} - {$sn['bb_p']}"; if($sn['bp']>0) $outr[$sn['bp']] .= (($outr[$sn['bp']]<>"")?", ":"")."{$if['show_bis_puppy']} - {$sn['bp_p']}"; if($sn['bj']>0) $outr[$sn['bj']] .= (($outr[$sn['bj']]<>"")?", ":"")."{$if['show_bis_junior']} - {$sn['bj_p']}"; if($sn['bs']>0) $outr[$sn['bs']] .= (($outr[$sn['bs']]<>"")?", ":"")."{$if['show_bis_senior']} - {$sn['bs_p']}"; if($sn['big']>0) $outr[$sn['big']] .= (($outr[$sn['big']]<>"")?", ":"")."{$if['show_bis_big']} - {$sn['big_p']}"; if($sn['bis']>0) $outr[$sn['bis']] .= (($outr[$sn['bis']]<>"")?", ":"")."{$if['show_bis_bis']} - {$sn['bis_p']}"; return $outr; } function ConvertDate($dt,$rev=FALSE) { // $rev - èç íîðìàëüíîé â MySQL, NOT $rev - èç MySQL â íîðìàëüíóþ if($rev) $retstr = substr($dt,6,4)."-". substr($dt,3,2)."-". substr($dt,0,2); else $retstr = substr($dt,8,2).".". substr($dt,5,2).".". substr($dt,0,4); return $retstr; }; function NormNameString($str) { // ôóíêöèÿ ïðåîáðàçóþùàÿ ñòðîêó - èìÿ (ôàìèëèþ, îò÷åñòâî) â âèä çàãëàâíàÿ-ñòðî÷íûå $retstr = trim($str); $retstr = strtoupper(substr($retstr,0,1)).strtolower(substr($retstr,1,strlen($retstr)-1)); return $retstr; } function NormDogName($str) { while($n = strpos($str, " ")) { $part = substr($str, 0, $n); $retstr .= ($retstr?" ":"") . NormNameString($part); $str = substr($str, $n + 1); } $retstr .= ($retstr?" ":"") . NormNameString($str); $retstr = str_replace(" Z ", " z ", $retstr); $retstr = str_replace(" Ñ ", " ñ ", $retstr); $retstr = str_replace(" S ", " s ", $retstr); $retstr = str_replace(" Vom ", " vom ", $retstr); $retstr = str_replace(" Fci", " FCI", $retstr); $retstr = str_replace(" Von ", " von ", $retstr); $retstr = str_replace(" Von Den ", " von den ", $retstr); $retstr = str_replace(" Von Der ", " von der ", $retstr); $retstr = str_replace(" V.d. ", " v.d. ", $retstr); $retstr = str_replace(" Iz ", " iz ", $retstr); $retstr = str_replace(" Èç ", " èç ", $retstr); $retstr = str_replace(" Ze ", " ze ", $retstr); $retstr = str_replace("-k", "-K", $retstr); $retstr = str_replace("-m", "-M", $retstr); return($retstr); } function UpdateDogField($id, $ra) { GLOBAL $if; SQLConn(); $q = "UPDATE dogs SET "; foreach($ra AS $key => $value) { $value = Shield($value); $ustr .= ($ustr?", ":"") . "$key=\"$value\""; } $q .= $ustr . " WHERE id=".(int)$id." LIMIT 1"; if(mysql_query($q)) { UpdateDate($id); $retstr = FALSE; } else $retstr = "

".mysql_error()."

"; return $retstr; } function ErrMsg($msg) { return "
$msg
"; } ?> "; echo ""; // echo " {$if['main_breed']}" .($id?(" - ".DogFullName($id)." ID: $id"):" - {$if['main_title']}").""; echo " SHIH-TZU" .($id?(" - ".DogFullName($id)." ID: $id"):" - Virtual Breed Database").""; echo " "; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo " "; // echo $jq?$jq:""; echo ""; echo "
"; } function Page_AuthForm($userid = FALSE) { GLOBAL $if; if($userid) { $outtext .= "{$if['mess_user_authorized']} ".ShowNames($userid,'users')."."; } else { $outtext .= "
"; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= "
{$if['index_reg_login']}:
{$if['index_reg_password']}:
"; $outtext .= "
"; } return $outtext; } function Page_Title($userid = FALSE) { GLOBAL $if; $outtext = "
"; GLOBAL $if; $outtext .= ""; $outtext .= ""; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= ""; $outtext .= "

{$if['title_header']}

"; $outtext .= "
"; $outtext .= Page_AuthForm($userid); $outtext .= "
"; $outtext .= " "; $outtext .= "
"; $outtext .= "
"; return $outtext; } function LangUrl($urlstr, $langid = 1) { $islang = strpos($urlstr, 'userif'); $isq = strpos($urlstr, '?'); if($islang !== FALSE) $urlstr[$islang+7] = $langid; elseif($isq) $urlstr = $urlstr ."&userif=$langid"; else $urlstr = $urlstr ."?userif=$langid"; return $urlstr; } function Page_Menu($userid = FALSE) { GLOBAL $if; $ustr = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $outtext .= "
"; $outtext .= ""; $outtext .= ""; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= (!$userid?" ":""); // $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= ""; $outtext .= "
{$if['menu_index']} {$if['menu_results']} {$if['menu_kennels']} {$if['menu_judges']} {$if['index_stat']} {$if['menu_registration']} «?» {$if['menu_help']}
"; $outtext .= "
"; return $outtext; } function Page_Alphabet() { $outtext .= "
"; $outtext .= "
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z � Б В Г Д Е Ж З И К Л М � О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я
"; $outtext .= "
"; return $outtext; } function Page_Operations($id = FALSE, $userid = FALSE, $div = TRUE) { GLOBAL $if; if($div) $outtext .= "
"; if($userid) { if($id) { $tmp = data_select( array('sex' => 0, 'fatherid' => 0, 'motherid' => 0, 'breeder' => 0, 'kennelid' => 0, 'datebirth' => 0), array('id' => (int)$id), 'dogs'); if($tmp['sex'] == 2) $male = TRUE; else $male=FALSE; $lmstr = ($tmp['fatherid']?"fatherid={$tmp['fatherid']}":""); $lmstr = ($lmstr?"&":"").($tmp['motherid']?"motherid={$tmp['motherid']}":""); } if(is_admin($userid)) $rc = data_select(array('COUNT(id)' => 'cnt'), array('active' => 0), 'dogs'); $outtext .= ""; $outtext .= ""; $outtext .= " "; $outtext .= " "; $outtext .= " "; if(is_admin($userid)) { $outtext .= " "; } $outtext .= " "; $outtext .= ""; $outtext .= "
"; // добавление �обак $outtext .= " "; $outtext .= " "; // вы�тавки $outtext .= " "; $outtext .= " "; // �правочники $outtext .= " "; $outtext .= " "; // �и�темные �правочники $outtext .= " "; $outtext .= " "; // �лужебные $outtext .= " "; $outtext .= "
"; } else $outtext .= ""; if($div) $outtext .= "
"; return $outtext; } function Page_Search () { GLOBAL $if; $outtext .= ""; return $outtext; } function Page_BaseSearch() { GLOBAL $if; $outtext .= ""; $outtext .= ""; $outtext .= " "; $outtext .= " "; $outtext .= ""; $outtext .= "
{$if['search_show_advanced']} ↓
"; return $outtext; } function Page_AdvSearch () { GLOBAL $if; $outtext .= "
"; $outtext .= ""; $outtext .= ""; $outtext .= " "; /* $outtext .= " "; */ $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= ""; $outtext .= ""; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= ""; $outtext .= ""; $outtext .= " "; $outtext .= " "; $outtext .= " "; $outtext .= ""; $outtext .= ""; $outtext .= " "; $outtext .= " "; $outtext .= ""; $outtext .= "
"; $outtext .= "
ID
"; $outtext .= "
"; $outtext .= "
"; $outtext .= "
{$if['common_owner']}
"; $outtext .= "
"; $outtext .= "
"; $outtext .= "
{$if['title_titles']}
"; $outtext .= "
".FormList('stitleid', 'titlestype', FALSE, array('eng' => TRUE))."
"; $outtext .= "
"; $outtext .= "
{$if['common_country']}
"; $outtext .= "
".FormList('Country','countries',FALSE, array('eng' => ($if['id'] != 1), 'trim' => 28)) ."
"; $outtext .= "
"; $outtext .= "
{$if['common_datebirth']}
"; $outtext .= "
-
"; $outtext .= "
"; $outtext .= "
{$if['common_name']}
"; $outtext .= "
"; $outtext .= "
{$if['common_kennel']} ({$if['common_owner']})
"; $outtext .= "
".FormList('Kennel','kennels',FALSE, array('eng' => ($if['id'] != 1), 'trim' => 28))."
"; $outtext .= "
"; $outtext .= "
{$if['common_address']}
"; $outtext .= "
"; $outtext .= "
"; $outtext .= "
{$if['main_search_byname']}
"; $outtext .= "
{$if['main_search_bykennels']}
"; $outtext .= "
{$if['main_search_bydatebirth']}
"; $outtext .= "
{$if['main_search_byupdate']}
"; $outtext .= "
{$if['main_search_byinsert']}
"; $outtext .= "
 
"; $outtext .= "
"; $outtext .= "
"; $outtext .= "
{$if['common_color']}
"; $outtext .= "
".FormList('Color','colors', FALSE, array('eng' => ($if['id'] != 1)))."
"; $outtext .= "
"; $outtext .= "
{$if['dog_title_pedigree']}
"; $outtext .= "
"; $outtext .= "
"; $outtext .= "
{$if['dog_title_dysp']}
"; $outtext .= "
{$if['search_withfoto']}
"; $outtext .= "
{$if['search_forsale']}
"; $outtext .= "
"; $outtext .= "
{$if['common_sex']}
"; $outtext .= "
"; $outtext .= "
"; $outtext .= "
{$if['dog_title_tattoo']}
"; $outtext .= "
"; $outtext .= "
"; $outtext .= "
"; return $outtext; } function FormHeader($id = FALSE, $userid = FALSE, $jq = FALSE) { GLOBAL $if; LiteHeader($id, $jq); echo Page_Menu($userid); echo Page_Title($userid); echo Page_Operations($id, $userid); echo Page_Alphabet(); echo Page_Search(); echo "
"; }; function FormEnding($userid = FALSE) { GLOBAL $if; echo "
"; /* echo "
"; if($userid) echo "* {$if['feedback_link']}"; else echo "   "; echo "
"; */ echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo << ЯндекÑ�.Метрика EOT; echo ""; echo "Web scripts ''Virtual breed database 2.0'' - Copyright ©, 2004-".date(Y)." Y.Semenov - All rights reserved. // Site opens 14, august 2018"; echo "
"; echo "
"; LiteEnding(); } function LiteEnding() { echo ""; echo ""; } function FormFeedback() { GLOBAL $if; $outtext .= "
"; $outtext .= ""; $outtext .= ""; $outtext .= " "; $outtext .= " "; $outtext .= ""; $outtext .= "

{$if['sendmail_info']}
"; $outtext .= "
"; return $outtext; } function Title($title, $context) { $retstr .= "
"; $retstr .= " $title
"; if($context <> "") { $retstr .= "
"; $retstr .= " "; $retstr .= " $context"; $retstr .= " "; $retstr .= "
"; } $retstr .= "
"; return $retstr; } function TitleBlock($title, $links, $text = FALSE, $pre_lenght = 86, $cssid = FALSE) { if(is_array($links)) foreach($links as $name => $url) $context .= ($context?" / ":""). "$name"; else $context = $links; $retstr .= title($title, $context); $retstr .= "
$text
"; return $retstr; }; function InfoBlock($title, $links, $text = FALSE, $pre_lenght = FALSE, $cssid = FALSE) { $retstr .= "
"; $retstr .= "

$title"; $retstr .= ($links?"
$links
":""); $retstr .= "

"; $retstr .= $text; $retstr .= "
"; return $retstr; }; function DictBlock($title, $text = FALSE, $cssid = FALSE) { $retstr .= "
\n"; $retstr .= "

$title

\n"; $retstr .= $text; $retstr .= "
\n"; return $retstr; }; function TwoColumns($c1, $c2) { echo ""; echo ""; echo " "; echo " "; echo ""; echo "
$c1 $c2
"; }; ?>'','motherid'=>''); else $row=mysql_fetch_array($dta); }; if(!IsActive($row['fatherid'])) $row['fatherid']="" ; if(!IsActive($row['motherid'])) $row['motherid']="" ; if($id && $base != $carr[$id]['base']) { $carr[$id]['count']++; $carr[$id]['base'] = $base; } if($level) { $carr = PdCount($row['fatherid'],$level-1,$carr,$id); $carr = PdCount($row['motherid'],$level-1,$carr,$id); }; return $carr; }; function PdColors($carr) { $clarr = array ( 1 => '#FFC9C9', 2 => '#FFF4C9', 3 => '#F4FF7C', 4 => '#D3FFB3', 5 => '#B3FFF9', 6 => '#B3D1FF', 7 => '#D3BBFF', 8 => '#B3FFD3', 9 => '#FFBBF1', 10 => '#DEF8B1'); if(is_array($carr)) foreach($carr as $cid => $cc) { if($cc['count'] < 2) unset($carr[$cid]); } $i = 1; if(is_array($carr)) foreach($carr as $cid => $cc) { $carr[$cid] = $clarr[$i]; $i++; }; return $carr; } function Pedigree($id, $level=3, $params = FALSE, $carr = FALSE) { // ïðîâåðêà ìàññèâ ïàðàìåòðîâ îôîðìëåíèÿ if(!$params) $params = array(); if(!$params['size']) $params['size'] = '8.0pt'; if(!$params['font']) $params['font'] = 'Tahoma'; if(!isset($params['dataset'])) { $ds['rkf'] = FALSE; $ds['hd'] = TRUE; $ds['titles'] = TRUE; $ds['study'] = TRUE; $ds['owner'] = FALSE; $ds['height'] = FALSE; $ds['country'] = TRUE; $ds['year'] = FALSE; $ds['col'] = TRUE; } else $ds = $params['dataset']; GLOBAL $if; GLOBAL $userid; SQLConn(); if(is_admin($userid)) $qstr = "SELECT d.cid, d.sex, d.fatherid, d.motherid, d.datebirth, d.rkf, ".(($if['id'] == 1)?"countries.name":"countries.little")." as cname, d.owner, ".(($if['id']==1)?"d.name AS dogname":"d.engname AS dogname").", dg.gene_k FROM dogs as d LEFT JOIN countries ON d.countryid=countries.id LEFT JOIN dogs_gene AS dg ON d.id=dg.dogid WHERE d.id=$id"; else $qstr = "SELECT d.cid, d.sex, d.fatherid, d.motherid, d.datebirth, d.rkf, countries.little, d.owner, ".(($if['id']==1)?"d.name AS dogname":"d.engname AS dogname")." FROM dogs as d LEFT JOIN countries ON d.countryid=countries.id WHERE d.id=$id"; $dta=mysql_query($qstr); if(!$row) { if(!$dta) $row=array('fatherid'=>'','motherid'=>''); else $row=mysql_fetch_array($dta); }; if(!IsActive($row['fatherid'])) $row['fatherid']="" ; if(!IsActive($row['motherid'])) $row['motherid']="" ; if($carr[$id]) $bgcol = $carr[$id]; else $bgcol = "#ffffff"; if($params['ph'] && file_exists("ph/$id-0.jpg")) $p_link = "
"; if($ds['rkf']) $rkfstr = ShowRKF($id); // if($ds['hd']) $hdstr = ShowHealth($id); if($hdstr) $hdstr = "$hdstr"; if($ds['titles']) $titstr = ShowTitles($id,", ",5); if($ds['study']) $titstr .= ($titstr?"
":"").ShowStudy($id, ', '); if($ds['height']) { $dm = data_select('tall', array('dogid' => $id), 'dogsize'); $sizestr = $dm['tall']; } if($ds['country'] && $row['cname']) $countrystr = $row['cname']; if($row['datebirth']) $year = substr($row['datebirth'],0,4); if($year == "0000" || !$ds['year']) $year = FALSE; if($ds['col'] && $row['cid']) $colstr = "
".ShowNames($row['col'], 'colors', ($if['id']==1)?FALSE:TRUE); if(is_admin($userid) && $row['gene_k'] > 0) $genestr = "

".ShowNames($row['gene_k'], 'gen_k')."

"; $retstr .= "". $p_link. ($titstr?"$titstr
":""). "". DogFullName($id,TRUE,$addinfo, array('color' => '#0000ff')). "". "
". "". ($rkfstr?"$rkfstr":""). ($hdstr?", $hdstr":""). (($row['owner'] && $ds['owner'])?"
".str_replace("&", "&", $row['owner'])."":""). ($sizestr?"

$sizestr cm

":""). ($countrystr?"

$countrystr

":""). ($year?"

$year

":""). $colstr. "$genestr
"; $retstr .= "\n"; if($level) $retstr = $retstr.Pedigree($row['fatherid'],$level-1,$params,$carr).Pedigree($row['motherid'],$level-1,$params,$carr); else $retstr = $retstr . "\n"; return $retstr; }; function InbreedSort($carr) { if(is_array($carr) && count($carr) > 0) { foreach($carr AS $k => $v) $ord[$k] = $v['level']; asort($ord); foreach($ord AS $k => $v) $ord[$k] = $carr[$k]; } else $ord = $carr; return $ord; } function InbreedStr($carr, $ceil = "; ") { if(is_array($carr)) foreach($carr AS $id => $ci) if($ci['count']>1) $retstr .= DogFullName($id, TRUE, FALSE, array('upper' => TRUE))." - ".$ci['str'].$ceil; return $retstr; } function Inbreed($id, $level=5, $carr, $base=FALSE, $step = 0) { SQLConn(); $qstr = "SELECT d.fatherid, d.motherid FROM dogs as d WHERE d.id=$id"; $dta=mysql_query($qstr); if(!$row) { if(!$dta) $row=array('fatherid'=>'','motherid'=>''); else $row=mysql_fetch_array($dta); }; if(!IsActive($row['fatherid'])) $row['fatherid'] = "" ; if(!IsActive($row['motherid'])) $row['motherid'] = "" ; if($id && ($base != $carr[$id]['base'] || !$base)) { $carr[$id]['count']++; $carr[$id]['str'] .= ($carr[$id]['str']?" , ":"").$step; $carr[$id]['base'] = $base; // äîáàâèì õðàíåíèå ìèíèìàëüíîãî óðîâíÿ âõîæäåíèÿ èíáðèäèíãà - ÷òîáû ïîòîì ñîðòèðîâàòü if(!$carr[$id]['level'] || ($carr[$id]['level'] > $step)) $carr[$id]['level'] = $step; } if($level) { $carr = Inbreed($row['fatherid'], $level-1, $carr, $id, $step + 1); $carr = Inbreed($row['motherid'], $level-1, $carr, $id, $step + 1); }; return $carr; }; function InbreedArray($da, $level = 4, $base = 1) { $fib_array = Inbreed($da['fatherid'],$level,FALSE,FALSE,$base); $mib_array = Inbreed($da['motherid'],$level,FALSE,FALSE,$base); if(is_array($fib_array)) foreach($fib_array as $fid => $fi) { if(!$mib_array[$fid] || $mib_array[$fid]['base'] == $fi['base']) unset($fib_array[$fid]); else { $fib_array[$fid]['str'] .= " : ".$mib_array[$fid]['str']; $fib_array[$fid]['count'] += $mib_array[$fid]['count']; $fib_array[$fid]['level'] = min($fib_array[$fid]['level'],$mib_array[$fid]['level']); } } return $fib_array; } function PedigreeArray($id, $level, $ar) { $n = count($ar) + 1; $ar[$n]['pid'] = $id; $ar[$n]['level'] = $level; if($level<4) { $r = data_select(array('fatherid' => 0, 'motherid' => 0), array('id' => $id), 'dogs'); if($r['fatherid']) $ar = PedigreeArray($r['fatherid'], $level + 1, $ar); if($r['motherid']) $ar = PedigreeArray($r['motherid'], $level + 1, $ar); } return $ar; } function PedigreeDBupdate($id, $ar) { $id = (int)$id; mysql_query("DELETE FROM pd WHERE id = $id"); foreach($ar as $n => $el) mysql_query("INSERT INTO pd VALUES($id, $n, {$el['level']}, {$el['pid']})"); } function PedigreesAll() { $dtd = mysql_query("SELECT id, fatherid, motherid FROM dogs ORDER BY id LIMIT 12000, 2000"); while($r = mysql_fetch_array($dtd)) { $ar = array(); $ar = PedigreeArray($r['fatherid'], 1, $ar); $ar = PedigreeArray($r['motherid'], 1, $ar); PedigreeDBupdate($r['id'], $ar); } } function PedigreeUpdateOffsprings($id) { $id = (int)$id; $dtd = mysql_query("SELECT d.id, d.fatherid, d.motherid FROM dogs AS d, pd AS p WHERE d.id=p.id AND p.pid=$id AND p.level<=3"); while($r = mysql_fetch_array($dtd)) { $ar = array(); $ar = PedigreeArray($r['fatherid'], 1, $ar); $ar = PedigreeArray($r['motherid'], 1, $ar); PedigreeDBupdate($r['id'], $ar); } } ?>